/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ChateoController;

import java.util.GregorianCalendar;

/**
 *
 * @author adrian
 */
public class ChatMessage {
    private String text;
    private User sender;
    private User receiver;
    private boolean privato;
    private GregorianCalendar date;
    private static int nbrMessage=0;
    private int id;
    
    public ChatMessage(String text , User sender , User receiver , boolean privato){
        this.date=new GregorianCalendar();
        this.text=text;
        this.sender=sender;
        this.receiver=receiver;
        this.privato=privato;
        nbrMessage++;
        this.id=nbrMessage;
        
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public User getSender() {
        return sender;
    }

    public void setSender(User sender) {
        this.sender = sender;
    }

    public User getReceiver() {
        return receiver;
    }

    public void setReceiver(User receiver) {
        this.receiver = receiver;
    }

    public GregorianCalendar getDate() {
        return date;
    }

    public void setDate(GregorianCalendar date) {
        this.date = date;
    }

    public static int getNbrMessage() {
        return nbrMessage;
    }

    public static void setNbrMessage(int nbrMessage) {
        ChatMessage.nbrMessage = nbrMessage;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    
    public String privacy(){
        if (this.privato){
            return "[Private]";
        }
        else{
            return "[Public]";
        }
    }
    
    @Override
    public String toString(){
        String out="";
        if (Controller.DebugMode()){
            //out = (this.privacy()+" MessageId = "+id+" Date = "+date.toString()+" \nSender ="+sender+"--> Receiver = "+receiver+" \nMessage: "+text+"\n---");
            out = (this.privacy()+" MessageId = "+id+"  Sender ="+sender+"--> Receiver = "+receiver+" \nMessage: "+text+"\n---");
        }
        else
        {
            //out = ("Date = "+date.toString()+" : "+sender+"-->"+receiver+" : Message: \""+text+"\"\n---");
            out = (sender+"-->"+receiver+" : Message: \""+text+"\"\n---");
        }
        return out;
    }
}
    
    
